<?php
// Only display Categories that have products
/*
    $strSQL = "SELECT DISTINCT
					  tblCategory.CategoryID
					, tblCategory.CategoryName
				FROM tblCategory, tblProducts
				WHERE tblCategory.CategoryID = tblProducts.CategoryID
				ORDER BY CategoryName;";
				//echo $strSQL;


    $strMenuSQL = "SELECT DISTINCT
					  tblCategory.ID CategoryID
					, tblCategory.Category 						CategoryName
					, tblCategory.Description 					CategoryDescription
					, tblSubCategory.SubCategory
					, tblSubCategory.ID SubCategoryID
				FROM tblCategory
				LEFT JOIN tblSubCategory ON 
						tblCategory.ID = tblSubCategory.Category
				LEFT JOIN tblProduct ON 
						tblCategory.ID = tblProduct.Category
				WHERE tblProduct.ID IS NOT NULL and tblProduct.Discontinued !=1
				";
				//echo $strSQL;
	
					$strSQL = "CREATE TABLE tblMenu
								SELECT DISTINCT tblCategory.ID  
									, tblCategory.Category 
								FROM tblCategory
									LEFT JOIN tblProduct ON tblCategory.ID = tblProduct.Category
								WHERE tblProduct.ID IS NOT NULL and tblProduct.Discontinued = 0";
					include (MODULE . "/action/actMySqlResults");	
	*/
					$strMenuSQL = "SELECT *
									, tblCategory.Description 					CategoryDescription
									FROM tblMenu
									LEFT JOIN tblCategory ON 
										tblCategory.ID = tblMenu.CategoryID";
						
				//include (MODULE . "/action/actMySqlResultsMenu");		

	
	$strJoin = " WHERE ";

    if ($intMenuCategoryID){
        $strMenuSQL .= $strJoin."tblMenu.CategoryID = '$intMenuCategoryID'";
        $strJoin = " AND ";
		unset($intMenuCategoryID);
    }

	$strMenuSQL .= " ORDER BY CategoryName, SubCategory";
    include (MODULE . "/action/actMySqlResultsMenu");

?>
